import os

def rename_files(directory_path):
    i = 1
    for filename in os.listdir(directory_path):
        if filename.lower().endswith(('.jpg', '.jpeg', '.png', '.gif', '.bmp')):
            file_extension = os.path.splitext(filename)[1]
            new_filename = f"{i}{file_extension}"
            old_filepath = os.path.join(directory_path, filename)
            new_filepath = os.path.join(directory_path, new_filename)
            os.rename(old_filepath, new_filepath)
            print(f"Renamed {filename} to {new_filename}")
            i += 1

if __name__ == "__main__":
    target_directory = "E:/face_reco/capture/train/0"
    rename_files(target_directory)
